package com.h2cloud.aspect;

import com.h2cloud.aspect.runtimeEx.ExceptionResponse;
import com.h2cloud.depends.MessageException;
import com.h2cloud.depends.Response;
import org.springframework.stereotype.Service;

/**
 * @author: wulongkai
 * @create: 2022-08-27 01:06
 **/
@ExceptionResponse
@Service
public class WorkFlowBizService {

    public Response<Boolean> agree(int id, String name, boolean valid) {
        if (valid) {
            try {
                preApproveValidate();
            } catch (MessageException e) {
                System.out.println("invoke failed");
                return Response.getFailureResult("invoke failed");
            }
        }
        int i = 1 / 0;
        System.out.println("invoke success");
        return Response.getSuccessResult(true);
    }

    public void preApproveValidate() {
        throw new MessageException("Validate error!");
    }
}
